package flc.ast.dialog;

import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;

import com.blankj.utilcode.util.ToastUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;

import java.util.ArrayList;
import java.util.List;

import flc.ast.R;
import flc.ast.databinding.DialogAddAlbumBinding;
import stark.common.basic.base.BaseSmartDialog;

public class AddAlbumDialog extends BaseSmartDialog<DialogAddAlbumBinding> implements View.OnClickListener {


    public AddAlbumDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getGravity() {
        return Gravity.CENTER;
    }

    @Override
    protected boolean canceledOnTouchOutside() {
        return true;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_add_album;
    }

    @Override
    protected void initView(View view) {
        mDataBinding.tvCancel.setOnClickListener(this);
        mDataBinding.tvSave.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.tvCancel) {//取消
            dismiss();
        } else if (id == R.id.tvSave) {//保存
            String name = mDataBinding.etName.getText().toString();
            if (TextUtils.isEmpty(name)) {
                ToastUtils.showShort(getContext().getString(R.string.please_input_album_name));
                return;
            }
            dismiss();
            if (listener != null) {
                listener.clickSave(name);
            }
        }
    }


    private Listener listener;

    public void setListener(Listener listener) {
        this.listener = listener;
    }

    public interface Listener {
        void clickSave(String name);
    }
}
